import { game, native } from "cc";
import { IosInterface } from "myGlobalModule";
import { App } from "../../../src/app";
import { ShareInfo } from "../const/enumConst";
import { EventName } from "../const/eventName";
import { NativePlatform, Native_Operation } from "./nativePlatform";

export class IosPlatform extends NativePlatform {

	//初始化注册
	injectGlobalFun() {
		if (!window.ios) {
			window.ios = {} as IosInterface
		}
		window.ios.refreshBalance = () => {

		}
	}

	getUUid(): string {
		return '';
	}

	changeOrientation(isPortrait: boolean) {
		super.changeOrientation(isPortrait);
		// jsb.reflection.callStaticMethod("JsClass", "changeOrientation:", isPortrait);
	}

	savePictureToAlbum(data: string) {
	}
	copyToClipboard(content: string): void {
	}
	getClipboardContent(): Promise<string> {
		return new Promise(r => { r('') });
	}
	getPackageName(): Promise<string> {
		return new Promise(r => { r('') });
	}
	getAppVersion(): string {
		return '';
	}
	checkIsEmulator(): boolean {
		return false;
	}

	sendNativeMsg(operation: string, args: string) {
		native.bridge.sendToNative(operation, args);
	}
	receiveNativeMsg(operation: string, data: string) {
		switch (operation) {
			case Native_Operation.CheckIsEmulator://是否是模拟器
				if (!+data) {//禁止在模拟器上运行
					game.end();
				}
				break;

			case Native_Operation.UserInfo:
				App.event.emit(EventName.Game.USER_INFO, data);
				break;

			case Native_Operation.LeaveRoom:
				App.event.emit(EventName.Game.NATIVE_LEAVE_ROOM, data);
				break;

			case Native_Operation.PlayerTalk:
				App.event.emit(EventName.Game.NATIVE_PLAYER_TALK, data);
				break;

			default:
				break;
		}
	}


	faceBookLogin(): string {
		return "";
	}

	faceBookLoginOut(): boolean {
		return false;
	}

	loginGoogle(): string {
		return ""
	}

	loginOutGoogle(): boolean {
		return false
	}

	faceBookShare(content: ShareInfo) {
		return false;
	}

	whatsAppShare(url: string) {
		return false;
	}

	jsCallJava() {

	}

	jsCallIos(): void {

	}
}